package com.itzz.ssm.service.impl;


import com.itzz.ssm.domain.Role;
import com.itzz.ssm.mapper.RoleMapper;
import com.itzz.ssm.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @Author:liuweibo
 * @Date Create in 2021/8/11 14:28
 * @Description:
 */
@Service
public class RoleServiceImpl implements RoleService {
    @Autowired
    private RoleMapper roleMapper;
    @Override
    public List<Role> findRole() {
        return roleMapper.findRole();
    }



    /*添加角色*/
    @Override
    public void saveRole(Role role) {
        roleMapper.saveRole(role);
    }
    @Transactional
    @Override /*spring 注解事物声明 方法  类*/
    public void deleteRole(int id) {
        roleMapper.deleteRoleUser(id);//删除关系表
        /*在删除角色表之前需要先删除关联的关系表*/
        /*int i=1/0;*/ /*出现异常 事物回滚*/
        roleMapper.deleteRole(id);
    }




}
